package parts4.lesson42;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class Demo {
    public static void main(String[] args) throws InterruptedException {
        //创建自适应的线程池，但是里面没有线程
        ExecutorService executorService = Executors.newCachedThreadPool();
        for (int x = 0; x < 10; x++) {
            Thread.sleep(100);
            int index = x;
            executorService.submit(() -> {
                System.out.println(Thread.currentThread().getName() + ",x=" + index);
            });
        }
        executorService.shutdown();
    }
}
